Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make QRcode decoding non-blocking by doing it in a thread #39

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

Cheaterman
Copy link
Contributor

I noticed my entire application was frozen the first time I used zbarcam, this seems to fix it. 👍

Copy link
Collaborator

@AndreMiras AndreMiras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Cheaterman for giving it a try.
It looks OK on the diff even though I haven't tried.
Note the unit tests are failing, could you try to update your PR fixing them.
The error is:

>       symbols = self.zbarcam._detect_qrcode_frame(texture, code_types)
E       TypeError: _detect_qrcode_frame() missing 1 required positional argument: 'code_types'

refs https://travis-ci.com/github/kivy-garden/zbarcam/jobs/371384314

@Cheaterman
Copy link
Contributor Author

Thanks for taking a look @AndreMiras - lemme fix that (I changed the signature of _detect_qrcode_frame())

It takes pixels independently of texture because in normal usage the
decoding will be done in a separate thread (which therefore can't make
the required GL calls to access the pixels).
@Cheaterman
Copy link
Contributor Author

I think that will do :-)

@Cheaterman
Copy link
Contributor Author

Welp - this should be better. I had things set up in a way that wouldn't work if _on_camera_ready was never called - and it's not called in tests.

@Cheaterman
Copy link
Contributor Author

Haha, I'm silly, the tests need to run differently because of the now asynchronous nature of _detect_qrcode_frame() - I'll rewrite my code differently instead, leaving the function as it is, and using it inside of a separate threaded function.

@Cheaterman
Copy link
Contributor Author

It's "more or less" left as-is, since I need to pass the pixels separately (can't write to texture.pixels) ; I made it an optional kwarg and it uses texture.pixels by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants